package com.itheima.controller;

import com.itheima.mapper.OperateLogMapper;
import com.itheima.pojo.Empoto;
import com.itheima.pojo.LoginInfo;
import com.itheima.pojo.PageResult;
import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import com.itheima.service.OperateLogService;
import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j

public class LoginController {
    @Autowired
    private EmpService empService;
    @PostMapping("/login")
    public Result login(@RequestBody Empoto empoto, HttpSession session) {
        LoginInfo loginInfo = empService.login(empoto);
        session.setAttribute("loginInfo", loginInfo);
        return Result.success(loginInfo);
    }
    @Autowired
    private OperateLogService operateLogService;

    @GetMapping("/log/page")
    public Result getLog(Integer page, Integer pageSize){
        return operateLogService.page(page,pageSize);
    }
}
